/*     */ package dm.jdbc.util;
/*     */ 
/*     */ import java.util.NoSuchElementException;
/*     */ 
/*     */ public class List {
/*     */   public class Node {
/*     */     public Object data;
/*     */     public Node next;
/*     */     public Node previous;
/*     */     
/*     */     Node(Object d) {
/*  12 */       this.data = d;
/*  13 */       this.next = null;
/*  14 */       this.previous = null;
/*     */     }
/*     */   }
/*     */   
/*     */ 
/*  19 */   private Node Head = null;
/*  20 */   private Node Tail = null;
/*  21 */   private Node Pointer = null;
/*  22 */   private int Length = 0;
/*     */   
/*     */ 
/*     */   public void deleteAll()
/*     */   {
/*  27 */     this.Head = null;
/*  28 */     this.Tail = null;
/*  29 */     this.Pointer = null;
/*  30 */     this.Length = 0;
/*     */   }
/*     */   
/*     */   public Object getHead() {
/*  34 */     return this.Head.data;
/*     */   }
/*     */   
/*     */   public Object getTail() {
/*  38 */     return this.Tail.data;
/*     */   }
/*     */   
/*     */   public Node getTailNode() {
/*  42 */     return this.Tail;
/*     */   }
/*     */   
/*     */ 
/*     */   public void reset()
/*     */   {
/*  48 */     this.Pointer = null;
/*     */   }
/*     */   
/*     */ 
/*     */   public boolean isEmpty()
/*     */   {
/*  54 */     return this.Length == 0;
/*     */   }
/*     */   
/*     */ 
/*     */   public boolean isEnd()
/*     */   {
/*  60 */     if (this.Length == 0)
/*  61 */       throw new NullPointerException();
/*  62 */     if (this.Length == 1) {
/*  63 */       return true;
/*     */     }
/*  65 */     return cursor() == this.Tail;
/*     */   }
/*     */   
/*     */   public boolean hasNextObject() {
/*  69 */     if ((this.Length == 1) || (this.Length == 0)) {
/*  70 */       return false;
/*     */     }
/*  72 */     Node temp = cursor();
/*  73 */     if (temp == this.Tail) {
/*  74 */       return false;
/*     */     }
/*  76 */     return true;
/*     */   }
/*     */   
/*     */ 
/*     */   public Object nextNode()
/*     */   {
/*  82 */     if (this.Length == 1)
/*  83 */       throw new NoSuchElementException();
/*  84 */     if (this.Length == 0) {
/*  85 */       throw new NullPointerException();
/*     */     }
/*  87 */     Node temp = cursor();
/*  88 */     this.Pointer = temp;
/*  89 */     if (temp != this.Tail) {
/*  90 */       return temp.next.data;
/*     */     }
/*  92 */     throw new NoSuchElementException();
/*     */   }
/*     */   
/*     */   public Node next()
/*     */   {
/*  97 */     if (this.Length == 1)
/*  98 */       throw new NoSuchElementException();
/*  99 */     if (this.Length == 0) {
/* 100 */       throw new NullPointerException();
/*     */     }
/* 102 */     Node temp = cursor();
/* 103 */     this.Pointer = temp;
/* 104 */     if (temp != this.Tail) {
/* 105 */       return temp.next;
/*     */     }
/* 107 */     throw new NoSuchElementException();
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */   public Object currentNode()
/*     */   {
/* 114 */     Node temp = cursor();
/* 115 */     return temp.data;
/*     */   }
/*     */   
/*     */ 
/*     */   public void insert(Object d)
/*     */   {
/* 121 */     Node e = new Node(d);
/* 122 */     if (this.Length == 0) {
/* 123 */       this.Tail = e;
/* 124 */       this.Head = e;
/*     */     } else {
/* 126 */       Node temp = cursor();
/* 127 */       e.next = temp;
/* 128 */       e.previous = temp.previous;
/* 129 */       temp.previous.next = e;
/* 130 */       temp.previous = e;
/* 131 */       if (this.Pointer == null) {
/* 132 */         this.Head = e;
/*     */       } else
/* 134 */         this.Pointer.next = e;
/*     */     }
/* 136 */     this.Length += 1;
/*     */   }
/*     */   
/*     */ 
/*     */   public void addLast(Object d)
/*     */   {
/* 142 */     Node e = new Node(d);
/* 143 */     if (this.Length == 0) {
/* 144 */       this.Tail = e;
/* 145 */       this.Head = e;
/*     */     } else {
/* 147 */       e.next = null;
/* 148 */       e.previous = this.Tail;
/* 149 */       this.Tail.next = e;
/* 150 */       this.Tail = e;
/*     */     }
/* 152 */     this.Length += 1;
/*     */   }
/*     */   
/*     */ 
/*     */   public int size()
/*     */   {
/* 158 */     return this.Length;
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */   public Object remove()
/*     */   {
/* 165 */     if (this.Length == 0)
/* 166 */       throw new NoSuchElementException();
/* 167 */     Object temp; if (this.Length == 1) {
/* 168 */       Object temp = this.Head.data;
/* 169 */       deleteAll();
/*     */     } else {
/* 171 */       Node cur = cursor();
/* 172 */       temp = cur.data;
/* 173 */       if (cur == this.Head) {
/* 174 */         this.Head = cur.next;
/* 175 */         this.Head.previous = null;
/* 176 */       } else if (cur == this.Tail) {
/* 177 */         this.Pointer.next = null;
/* 178 */         this.Tail = this.Pointer;
/* 179 */         reset();
/*     */       } else {
/* 181 */         cur.next.previous = this.Pointer;
/* 182 */         this.Pointer.next = cur.next;
/*     */       }
/* 184 */       this.Length -= 1;
/*     */     }
/* 186 */     return temp;
/*     */   }
/*     */   
/*     */   public void removeAll() {
/* 190 */     reset();
/*     */     
/* 192 */     while (this.Length != 0) {
/* 193 */       remove();
/*     */     }
/*     */   }
/*     */   
/*     */   private Node cursor()
/*     */   {
/* 199 */     if (this.Head == null)
/* 200 */       throw new NullPointerException();
/* 201 */     if (this.Pointer == null) {
/* 202 */       return this.Head;
/*     */     }
/* 204 */     return this.Pointer.next;
/*     */   }
/*     */ }


/* Location:              D:\Program Files\DBMS_20150813\jdbc\Dm7JdbcDriver17.jar!\dm\jdbc\util\List.class
 * Java compiler version: 2 (46.0)
 * JD-Core Version:       0.7.1
 */